from typing import List


class Solution:
    def canDivideIntoSubsequences(self, nums: List[int], k: int) -> bool:
        last_val = nums[0]
        last_num = 0
        for n in nums:
            if last_val == n:
                last_num += 1
            else:
                last_val = n
                last_num = 1
            if last_num * k > len(nums):
                return False
        return True


if __name__ == "__main__":
    # True
    print(Solution().canDivideIntoSubsequences(nums=[1, 2, 2, 3, 3, 4, 4], k=3))

    # False
    print(Solution().canDivideIntoSubsequences(nums=[5, 6, 6, 7, 8], k=3))

    # 测试用例29/30 : True
    print(Solution().canDivideIntoSubsequences(nums=[1, 2, 3, 3], k=2))

    # 自制用例 True
    print(Solution().canDivideIntoSubsequences(nums=[1, 2, 3, 3, 3, 3, 4, 5], k=2))
